package com.javarush.test.level26.lesson15.big01.command;

import com.javarush.test.level26.lesson15.big01.CurrencyManipulator;
import com.javarush.test.level26.lesson15.big01.CurrencyManipulatorFactory;
import com.javarush.test.level26.lesson15.big01.exception.InterruptOperationException;

import java.util.ArrayList;

/**
 * Created by admin on 18.04.2015.
 */
class InfoCommand implements Command {
    @Override
    public void execute() throws InterruptOperationException {
        ArrayList<CurrencyManipulator> manipulators=new ArrayList<>();
        manipulators.addAll(CurrencyManipulatorFactory.getAllCurrencyManipulators());
        boolean money=false;

        for (CurrencyManipulator manipulator:manipulators){
            if (manipulator.hasMoney()) money=true;
        }

        if(money) {
            for (CurrencyManipulator manipulator : manipulators) {

                System.out.println(manipulator.getCurrencyCode() + " - " + manipulator.getTotalAmount());
            }
        }else{System.out.println("No money available.");
        }


    }
}
